// 二分搜索示例：
Array.prototype.binarySearch = function (item) {
    let low = 0
    let high = this.length - 1
    while (low <= high) {
        const mid = Math.floor((low + high) / 2)
        const element = this[mid]
        if (element < item) {
            low = mid + 1
        } else if (element > item) {
            high = mid - 1
        } else {
            return mid
        }
    }
    return -1
}
const res = [1, 2, 3, 4, 5].binarySearch(5)
console.log(res)
// 二分搜索效率比顺序搜索高，数组一定要是有序的，时间复杂度O（logN）
